import React,{useState} from 'react'

export default function StateHook2() {
  const [count,setCount]=useState(0)
  const increment=()=>{
    setCount(count=>count+1) // setCount(0=>1)
    console.log('count的值为:',count);
    setCount(count=>count+1) // setCount(1=>2)
    console.log('count的值为:',count);
    setCount(count=>count+1) // setCount(2=>3)
    console.log('count的值为:',count);
    setCount(count=>count+1) // setCount(3=>4)
    console.log('count的值为:',count);
  }
  return (
    <div>
        <h2>{count}</h2>
        <button onClick={increment}>更新</button>
    </div>
  )
}
